'The cursorIn has to be stored to prevent the funny hehavior in highlight/deHighlight. If it is not stored and restored, when one move a highlighted mode under another mode, the highlighted mode will remain highlighted even the cursor now is on top of the other mode and generates cursorMove events. If the cursorIn is kept, the dragged mode will be sent a leaveMode event to deHighlight itself when the cursorMove events are generated. Shan July 19, 1989'!
"Erase self but do not remove from the mode hierarchy."
" Shan March 19, 1989"
| topMode savedVisible |
"visible ifFalse: [^self]."
(dispObj isKindOf: AnimationDispObj)
ifTrue: [dispObj stopDisplayLoop].
"Shan May 31, 1989"
savedVisible _ self isVisible.
self setVisible: false.
topMode _ self topMode.
(self getVisibleRectsIn: nil)
do: [:each | topMode displayIn: each].
"Shan September 19, 1989"
self setVisible: "true" savedVisible!
scaledBackground
"Display background with saling. This is done by assigning the dispObj
a bounding box so that when my displayBox is changed, I can scale
the background according to the difference between the current
displayBox and the boundingBox of the dispObj. Make some
adjustment to avoid floating point transformations. Shan May 12,
1989 "
self displayObject boundingBox: (0 @ 0 extent: self window extent"Modified according to the chnages made in DispObj. Shan December 1, 1989 - (self borderWidth * 2)")! !
!Mode methodsFor: 'drag support'!
afterDrag: aSymbol
"This is sent by the drag loop after the drag finishes. Shan July 13,
1989"
self map.
self topMode recoverFromDrag: aSymbol!
beforeDrag: aSymbol
"This is sent by the drag loop before the drag starts. Mode should
set up the right controller for the dragging and propagate the
message down the mode hierarchy. Shan June 25, 1989"
"aSymbol can be #move or #link. Shan July 13, 1989"
self map.
"MoveImage erases (and therefore set the mode to invisible) before
drag. Shan July 14, 1989"
self topMode prepareForDrag: aSymbol.
"To avoid my controller from processing any events, especially the
enter/leave. Without this, there will be an extra enterMode event
generated by the old controller which thinks the cursor has moved
out of the area of the mode. Also avoid my own drag controller from
obscuring the process of events of the modes under me. Shan July 13,
1989"
aSymbol = #move ifTrue: [self unMap.]!
prepareForDrag: aSymbol
"Remember to propagate the changes here to PollingEnvMode. Shan July 12, 1989"
leaveEvent previousOrigin: temp. "Used in MenuCell>cursorLeave:. This point is not used to check who was left by the cursor now (replaced by using cursorIn), but is kept to make consistent that the origin of an event always corresponds to the place where it happens. Shan July 19, 1989"
leaveEvent selector: #leaveMode.
"process it."
topSubModeLeft processLeave: leaveEvent].
"Search for the subMode that was entered by the cursor. It should
be a subMode of commonAncestor and an ancestor of self."
"This is not changed to be recursively searching the mode hierarchy because sometimes it is desirable to display a mode even it is not visible on screen. e.g. buffering it into a form. Shan July 21, 1989"
^visible! !
!Mode methodsFor: 'bordering'!
borderColor
^dispObj borderColor!
borderColor: aColor
dispObj borderColor: aColor!
borderWidth
^dispObj borderWidth!
borderWidth: aWidth
dispObj borderWidth: aWidth!
insideColor
^dispObj insideColor!
insideColor: aColor
| previousColor |
previousColor _ dispObj insideColor.
dispObj insideColor: aColor.
"Changing the inside color from nil to something makes the transparent
window opaque. Recompute the layering. Shan April 12, 1989"
"This should generate the same result as the test2."
"Use the new creation method. And attachment methods"
"Shan - March 17 1989"
"Mode test21"
| v sb1 sb2 |
v _ RootMode origin: 250@10 extent: 200@200.
v borderWidth: 4; borderColor: Form lightGray.
v insideColor: Form white.
sb1 _ Mode extent: 80@80.
sb1 borderWidth: 2.
sb1 insideColor: Form gray.
v addSubMode: sb1 at: 50@50.
sb2 _ Mode origin: 100@100 extent: 200@200.
sb2 insideColor: Form veryLightGray.
sb2 borderWidth: 3.
v addSubMode: sb2.
v display!
test3
"This is a test for the optimization that prevents totally invisible views being processed. Notice that the clipping is also done here. The purpose is to cut down the recursion in the method of 'display'."
"There should only be 3 'self halt' executed. The one for su11 should be clipped. To test, uncomment the 'self halt' message in the 'display' method and run the test."
" Shan - 10 December 1988"
"Mode test3"
| v sb1 sb11 sb2 |
v _ RootMode new.
v borderWidth: 4; borderColor: Form lightGray.
v insideColor: Form white.
v window: (0@0 extent: 200@200) viewport: (10@10 extent: 200@200).
"This creates a Mode with its window and viewport of the same size."
"Shan June 6,1989"
^self new extent: extent!
origin: origin
"This creates a Mode with its window and viewport of the same size."
"Shan June 6,1989"
^self new origin: origin!
origin: origin extent: extent
"This creates a Mode with its window and viewport of the same size."
"Shan March 17,1989"
^self new origin: origin extent: extent! !
Mode initialize!
Mode subclass: #ExpandedMode
instanceVariableNames: 'painter '
classVariableNames: ''
poolDictionaries: ''
category: 'Modes-Shan'!
ExpandedMode comment:
'This class is to provide more functionality for Modes that accommondate other modes. It provides speedups like painter''s algorithm for drawing and mode based buffering. Shan July 21, 1989'!
!ExpandedMode methodsFor: 'layering'!
computeSubLayeringBelow: aSubView withIn: aRect
"Override to provide painter's algorithm. Shan April 23, 1989"
"This is the only difference between this method and
the one in Mode. Shan April 23, 1989"
(painter not and: [each isVisible & each insideColor notNil])
ifTrue: [subList add: each displayBox]]]!
isPainter
"If painter is true, Shan April 26, 1989"
^ painter!
setPainter: aBool
"If painter is true, the layering algorithm will not compute the effect
of peer modes for the subModes below me. Shan April 23, 1989"
painter _ aBool! !
!ExpandedMode methodsFor: 'initialize-release'!
initialize
super initialize.
painter _ false! !
ExpandedMode subclass: #ModeGroup
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Modes-Shan'!
ModeGroup comment:
'This class can be used to group modes together. The shape (involved in event processing and enter/leave business) is defined by the component modes. Example applications include ShrunkenWindow, LibraryObject, SemObjDelegate, and MessageLink. Shan August 24, 1989'!
!ModeGroup methodsFor: 'event handling'!
interestedIn: event
"This is the part of the event dispatching mechanism that decides
whether the mode should process the event. Shan August 24, 1989."